package com.amado.easyui2.dao.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import com.amado.easyui2.dao.ExportCarDao;
import com.amado.easyui2.domain.CoachCarEntity;

public class ExportCarDaoImpl implements ExportCarDao {

	@Override
	public List<CoachCarEntity> listAll() {
		Connection conn = JDBC.getConn();
		PreparedStatement ps = null;
		ResultSet rs = null;
		String sql = "SELECT * FROM t_coach_car";
		List<CoachCarEntity> coach = new ArrayList<CoachCarEntity>();
		try {
			ps = conn.prepareStatement(sql);
			rs = ps.executeQuery();
			while (rs.next()) {
				int i = 1;
				Long id = rs.getLong(i++);
				String bhAbbreviate = rs.getString(i++);
				
				String learnCardNumber = rs.getString(i++);
				String oldLearnCardNumber = rs.getString(i++);
				String carColoc = rs.getString(i++);
				String carrriageNumber = rs.getString(i++);
				String engineNumber = rs.getString(i++);
				String trainingModel = rs.getString(i++);
				String paraphraseWay = rs.getString(i++);
				String indexNumberNumber = rs.getString(i++);
				String bodyColorCar = rs.getString(i++);
				String automobileBrand = rs.getString(i++);
				String carType = rs.getString(i++);
				Date registerDay = rs.getDate(i++);
				Date comeintoserviceDay = rs.getDate(i++);
				Date yearCarefulTime = rs.getDate(i++);
				String yearCarefulState = rs.getString(i++);
				String deleteLogo = rs.getString(i++);
				Date createTime=rs.getTimestamp(i++);
				Date updateTime=rs.getTimestamp(i++);
				String createName=rs.getString(i++);
				String updateName=rs.getString(i++);
				coach.add(new CoachCarEntity(id, bhAbbreviate,deleteLogo,learnCardNumber, oldLearnCardNumber,
						carColoc, carrriageNumber, engineNumber,trainingModel, paraphraseWay, indexNumberNumber,
						bodyColorCar, automobileBrand, carType, registerDay, comeintoserviceDay, yearCarefulTime,
						yearCarefulState,createTime,updateTime,createName,updateName));
			}
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			JDBC.close(rs, ps, conn);
		}
		return coach;
	}

}
